package cn.edu.guet.tts.service.impl;

import cn.edu.guet.tts.entity.TbOrder;
import cn.edu.guet.tts.mapper.TbOrderMapper;
import cn.edu.guet.tts.service.ITbOrderService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 订单管理表 服务实现类
 * </p>
 *
 * @author test
 * @since 
 */
@Service
public class TbOrderServiceImpl extends ServiceImpl<TbOrderMapper, TbOrder> implements ITbOrderService {

    @Autowired
    private TbOrderMapper tbOrderMapper;

    @Override
    public int deleteByUserId(int userId) {
        return tbOrderMapper.deleteByUserId(userId);
    }

    @Override
    public List<Integer> getTicketIdByUserId(int userId) {
        return tbOrderMapper.getTicketIdByUserId(userId);
    }

    @Override
    public TbOrder getOrderByTicketId(Integer ticketId) {
        QueryWrapper<TbOrder> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("ticket_id", ticketId);
        return tbOrderMapper.selectOne(queryWrapper);
    }
}
